package leetcode.code2208;

import java.util.PriorityQueue;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int halveArray(int[] nums) {
		double sum = 0;
		PriorityQueue<Double> queue = new PriorityQueue<>((a, b) -> b.compareTo(a));
		for (int num : nums) {
			sum += num;
			queue.add((double) num);
		}
		int ans = 0;
		double sub = 0;
		while ((sub * 2) < sum) {
			double cur = queue.poll();
			sub += cur / 2;
			queue.add(cur / 2);
			ans++;
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
